<?php
	include('./init_admin.php');
	utils::checkadminauth();
	$flagupload = false;
	
	if (!empty($_FILES['pmedia']) && is_uploaded_file($_FILES['pmedia']['tmp_name']) ) {
		$flagupload = true;
		$new_file_path = ROOT_DIR . 'media/' . $_FILES['pmedia']['name'];
		$ufile = ABS_URL . 'media/' . $_FILES['pmedia']['name'];
		move_uploaded_file($_FILES['pmedia']['tmp_name'], $new_file_path);
		chmod ($new_file_path, 0644);
	}
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Pages</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
	if (!$flagupload) {
?>
<form name="frmumedia" method="POST" enctype="multipart/form-data">
<table style="width:100%;height:100%" cellspacing="2" cellpadding="0" border="1" align="left">
	<tr style="background-color:#bbbbbb;">
		<th height="35">Upload a media file</th>
	</tr>
	<tr>
		<td align="center"><input type="file" name="pmedia" size="30">
		<br><br><input type="submit" value="Submit file" class="btn"></td>
	</tr>
</table>
</form>
<?php
} else {
?>
<table style="width:100%;height:100%" cellspacing="2" cellpadding="0" border="1" align="left">
	<tr>
		<td align="center">
			The URL of the uploaded file is: <br><br>
			<a href="<?php echo $ufile;?>" target="_blank" class="menu"><?php echo $ufile;?></a>
			<br><br><br>
			<span class="mup" onclick="window.close()">Close window</span>
		</td>
	</tr>
</table>
<?php
}
?>
</body>
</html>